package com.java.test.demo.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

class MyThread1 implements Runnable{

    @Override
    public void run() {

    }
}

class MyThread2 implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        System.out.println("callable");
        return 1024;
    }
}
public class CallableDemo {
    public static void main(String[] args) throws Exception{
       FutureTask<Integer> futureTask= new FutureTask<Integer>(new MyThread2());
       new Thread(futureTask,"A").start();
       while (!futureTask.isDone()){

        }
       int result=futureTask.get();
        System.out.println(result);
    }
}
